﻿namespace UnityEditor
{
    using System;
    using UnityEngine;

    internal abstract class AnimValue
    {
        [NonSerialized]
        internal float m_LerpPos = 1f;
        protected object m_Source;
        private object m_Target;
        internal AnimValueManager owner;

        protected AnimValue()
        {
        }

        protected void BeginAnimating(object target, object value)
        {
            if (target.Equals(value) || ((this.m_Target != null) && this.m_Target.Equals(target)))
            {
                this.m_Target = target;
            }
            else
            {
                this.m_LerpPos = 0f;
                this.m_Source = value;
                this.m_Target = target;
                if (this.owner != null)
                {
                    this.owner.WantsUpdate();
                }
                else
                {
                    Debug.Log("Something is wrong. BeginAnimating with null owner");
                }
            }
        }

        protected object GetTarget(object def)
        {
            if (this.m_Target != null)
            {
                return this.m_Target;
            }
            return def;
        }

        protected void StopAnim(object value)
        {
            this.m_LerpPos = 1f;
            this.m_Target = value;
        }

        internal abstract void Update();

        protected float smoothed
        {
            get
            {
                float num = 1f - this.m_LerpPos;
                return (1f - (((num * num) * num) * num));
            }
        }

        internal bool wantsUpdate
        {
            get
            {
                return (this.m_LerpPos < 1f);
            }
        }
    }
}

